import { _decorator, Camera, Component, Node } from 'cc';
import { GLOBALVar } from './GlobalVar';
const { ccclass, property } = _decorator;

@ccclass('GlobalPop')
class GlobalPop extends Component {
    private static _instance: GlobalPop = null;
    private FailedPanel: Node | null = null;
    private CardContainer: Node | null = null;
    private Camera: Camera | null = null;
    public static getInstance(): GlobalPop {
        if (this._instance == null) {
            this._instance = new GlobalPop();
        }
        return this._instance;
    }

    public setFailedPanel(node: Node) {
        this.FailedPanel = node;
    }

    public setGameState(state: number) {
        switch (state) {
            case 0:
                //失败，重置关卡等级
                GLOBALVar.setClassicModeLevel(1);
                this.FailedPanel.active = true;
                break;
            case 1:
                //重开游戏
                this.FailedPanel.active = false;
                break;
        }
    }
    public setCardContainer(node: Node) {
        this.CardContainer = node;
    }
    public setCamera(camera: Camera) {
        this.Camera = camera;
    }
}
export const GLOBALPOP: GlobalPop = GlobalPop.getInstance();

